<?php

namespace backend\controllers;

use yii;
use backend\models\Country;

class CountryController extends \yii\web\Controller
{
    public function actionGetCity($province = 'package-province')
    {
        $model = new Country();
        $post = Yii::$app->request->post('depdrop_all_params');
        $pid = $post[$province];
        return json_encode(['output' => $model->getProvincesForDropdown("pid = $pid"), 'selected' => '']);
    }

    public function actionGetProjectSingleCity()
    {
        $model = new Country();
        $post = Yii::$app->request->post('depdrop_all_params');
        $pid = $post['projectsingle-province'];
        return json_encode(['output' => $model->getProvincesForDropdown("pid = $pid"), 'selected' => '']);
    }
    public function actionGetCustomerCity()
    {
        $model = new Country();
        $post = Yii::$app->request->post('depdrop_all_params');
        $pid = $post['customer-company_province'] ? $post['customer-company_province'] : $post['customer-company_province'];
        return json_encode(['output' => $model->getProvincesForDropdown("pid = $pid"), 'selected' => '']);

    }

}
